package com.zzq.my.jetpacks.jectpackapp.ui.act

import android.widget.Toast
import by.kirich1409.viewbindingdelegate.viewBinding
import com.aisier.architecture.base.BaseActivity
import com.jennifer.andy.androidxlazyload.demo.adapter.FragmentLazyPagerAdapter
import com.zzq.my.jetpacks.jectpackapp.R
import com.zzq.my.jetpacks.jectpackapp.databinding.Activity1Binding
import com.zzq.my.jetpacks.jectpackapp.generate123FragmentTitles
import com.zzq.my.jetpacks.jectpackapp.generate123Fragments
import com.zzq.my.jetpacks.util.setSafeListener

/**
 * 描述：ViewPager + FragmentPagerAdapter
 * 作者：zhuangzeqin
 * 时间: 2022/1/18-17:04
 * 邮箱：zzq@eeepay.cn
 * 备注:
 */
class Activity1 : BaseActivity(R.layout.activity_1) {
    private val vb by viewBinding(Activity1Binding::bind)

    /**
     * 初始化数据
     */
    override fun initData() {


    }

    /**
     * 初始化操作
     */
    override fun initView() {
       val viewPager = vb.viewPager.apply {
            adapter = FragmentLazyPagerAdapter(
                supportFragmentManager, generate123Fragments().values.toMutableList(),
                generate123FragmentTitles()
            )
        }
        vb.tabLayout.setupWithViewPager(viewPager)
        //防爆点击事件
        viewPager.setSafeListener {
            Toast.makeText(this@Activity1, "防爆点击事件", Toast.LENGTH_SHORT).show()
        }
    }

    /**
     * 初始化点击事件操作
     */
    override fun eventOnClick() {

    }
}